package com.mall.web.control.app.citylife;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mall.client.commkey.CommKeyService;
import com.mall.common.util.bit.PropertiesConfigure;
import com.mall.pojo.City;
import com.mall.pojo.Commkey;
import com.mall.pojo.User;
import com.mall.web.util.APPCookieUtil;
import com.mall.web.util.HttpUtil;
import com.mall.web.util.WebUtil;

@Controller
@RequestMapping("life")
public class CityLifeForPayMentController {
	
	@Autowired
	private PropertiesConfigure propertiesConfigure;
	@Autowired
	private CommKeyService commKeyService;

	/**
	 * 生活缴费首页
	 * 
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 */
	@RequestMapping("lifeindex")
	public String lifeindex(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
		int app = APPCookieUtil.urlFromApp(request);
		Integer onlyKey = HttpUtil.getCommkeyId(request, response);
		modelMap.put("app", app);
		/**
		 * 根据onlykey存对应的省市区
		 */
		List<Commkey> commKeyList = this.commKeyService.getComKeyByCommOnlyKey(onlyKey);
//		List<Integer> typeList = this.mallCompanyPayInfoService.getDistinctTypeFromCity(mallcity);
//		modelMap.put("typeList", typeList);
		return "mall/lifeindex";
	}

//	@RequestMapping("lifedetail")
//	public String lifedetail(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
//		Integer payType = HttpUtil.getIntegerValueFromRequest(request, "payType");
//		Integer type = HttpUtil.getIntegerValueHasDefaultFromRequest(request, "type", 0);
//		Integer mallcity = WebUtil.getAppCityIdAndPutToCookie(request, response);
//		Long companyId = HttpUtil.getLongValueFromRequest(request, "companyId");
//		modelMap.put("payType", payType);
//		modelMap.put("type", type);
//		modelMap.put("mallcity", mallcity);
//		User user = WebUtil.getCurrentUser(request);
//		UserPayInfo userPayInfo = lifePaymentService.getUserPayInfoByUserIdAndType(user.getId(), payType, mallcity,
//				type);
//		modelMap.put("userPayInfo", userPayInfo);
//		City city = provinceAndCityService.getCityByCityId(mallcity);
//		modelMap.put("city", city);
//		if (companyId != null && companyId > 0) {
//			MallCompanyPayInfo mallCompanyPayInfo = this.mallCompanyPayInfoService.getMallCompanyPayInfoById(companyId);
//			modelMap.put("mallCompanyPayInfo", mallCompanyPayInfo);
//		}
//
//		return "mall/lifedetail";
//	}
//
//	@RequestMapping("lifecompanylist")
//	public String lifecompanylist(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
//
//		Integer type = HttpUtil.getIntegerValueHasDefaultFromRequest(request, "type", 0);
//		Integer mallcity = HttpUtil.getIntegerValueFromRequest(request, "mallcity");
//		modelMap.put("type", type);
//		modelMap.put("mallcity", mallcity);
//		List<MallCompanyPayInfo> mallCompanyPayInfoList = this.mallCompanyPayInfoService
//				.getMallCompanyPayInfoListByTypeAndCity(mallcity, type);
//		modelMap.put("mallCompanyPayInfoList", mallCompanyPayInfoList);
//		City city = provinceAndCityService.getCityByCityId(mallcity);
//		modelMap.put("city", city);
//		String referer = HttpUtil.getHttpReferer(request);
//		modelMap.put("referer", referer);
//		return "mall/lifecompanylist";
//	}
//
////	/**
////	 * 生活缴费首页
////	 * 
////	 * @param request
////	 * @param response
////	 * @param modelMap
////	 * @return
////	 */
//	@RequestMapping("test")
//	public String test(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
//		return "mall/testindex";
//	}
}
